package com.yezi.lampcourt.ui;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.Button;

import com.yezi.lampcourt.R;
import com.yezi.lampcourt.base.BaseActivity;
import com.yezi.lampcourt.base.LoadingDialog;

import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.annotations.NonNull;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;

/**
 * Created by HongMing Ye
 * on 2017/10/11 0011.
 */

public class TestActivity extends BaseActivity {
    @BindView(R.id.demo_start)
    Button mDemoStart;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actvity_test);
        ButterKnife.bind(this);
        init();
    }

    @Override
    protected void init() {

    }

    @OnClick(R.id.demo_start)
    public void onViewClicked() {
        final LoadingDialog loadingDialog = new LoadingDialog(this);
        loadingDialog.show();
        Observable.interval(5, TimeUnit.SECONDS)
                .subscribeOn(Schedulers.computation())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer<Long>() {
                    @Override
                    public void accept(@NonNull Long aLong) throws Exception {
                        loadingDialog.hide();
                    }
                });

    }

}
